Skip to content

fix(npu): serialize kernel registry access#2

Draft
pjgao wants to merge 1 commit into
xLLM-AI:mainfrom
pjgao:fix/kernel-registry-thread-safety
Draft

fix(npu): serialize kernel registry access#2
pjgao wants to merge 1 commit into
xLLM-AI:mainfrom
pjgao:fix/kernel-registry-thread-safety

Conversation

@pjgao

@pjgao pjgao commented Jul 21, 2026

Copy link
Copy Markdown

改动概述

对进程级 NPU KernelRegistry 的读取、注册和清理进行串行化。

修改原因

KernelRegistry 是进程级 singleton,Triton NPU 算子采用先查询、再按需注册的懒加载方式。多个线程并发首次调用不同或相同 kernel 时,可能同时读写 kernel_infos_;C++ 容器的并发读写属于未定义行为。

本修改在注册、查询 workspace、获取 stub 和清理入口使用同一把进程级互斥锁,保证 registry 内部状态的一致性。该问题与具体模型和 MegaMoe 无关,属于通用的 Triton NPU runtime 线程安全修复。

验证结果与边界

  • 受影响的 translation unit 已随 xLLM CANN 9.1 构建通过。
  • 下游 Qwen3.5 EP8 集成曾完成真实生成与并发 smoke,但该结果同时包含其他 MegaMoe 修复,不能单独证明本 registry 修改的必要性。
  • 当前 PR 尚缺少专门覆盖并发首次注册、并发查询与注册交错的 focused test;该测试应作为本 PR 自身的后续验证门禁。

本 PR 不修复 MegaMoe 跨 rank 随机 token 问题,也不应以 MegaMoe 精度结果作为直接验证证据。

下游依赖

  • 本 PR 作为独立的通用线程安全修复推进。
  • xLLM #1989 的 MegaMoe 接入不以本 PR 为硬依赖。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant